package admin.forms;

import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;

import entities.AdsenseAdv;


public class AdsenseAdvForm {
	
	public static TreeMap<String, Object> checkValid(HttpServletRequest request, AdsenseAdv ads) {
		TreeMap<String, Object> form = new TreeMap<String, Object>();
		TreeMap<String, String> check = new TreeMap<String, String>();
		
		String name = (String) request.getParameter("name");
		String content = (String) request.getParameter("content");
		
		if (name == null || name.isEmpty()) {
			check.put("name", "Name is not empty!");
			ads.setName("");
		} else {
			ads.setName(name);
		}
		
		if (content != null) {
			ads.setContent(content);
		}
		
		form.put("checkValid", check);
		form.put("ads", ads);
		
		return form;
	}
}
